#ifndef _GRAPH_OPENGL__HPP
#define _GRAPH_OPENGL__HPP

#include <iostream>
#include <string>
#include <map>
#include <SDL/SDL.h>
#include <SDL/SDL_ttf.h>
#include <SDL/SDL_image.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "IGraph.hpp"

class Graphics : public IGraph
{
public:
  Graphics(int argc, char **argv, int w, int h);
  void loadImages(const std::map<IGraph::Image, std::string> &loadMap);
  void drawBlock(IGraph::Image img, int x, int y);
  void openWindow();
  IGraph::Event getNextEvent();
  void wait(unsigned int d) const;
  unsigned int getCurrentTime() const;
  void display();
  void clearScreen(char r, char g, char b);
  void loadFont(const std::string &fontPath);
  void writeText(char r, char g, char b, const std::string &text, int x, int y);
  Point getTextSize(const std::string &text) const;
  void pause();
  ~Graphics();

private:
  std::map<IGraph::Image, GLuint> _imgMap;
  int _w;
  int _h;
  SDL_Event e;
  TTF_Font *_font;
};

extern "C" IGraph *create(int argc, char **argv, int w, int h)
{
  return new Graphics(argc, argv, w, h);
}

extern "C" void destroy(IGraph *obj)
{
  delete obj;
}

#endif
